import React, { Component } from "react";
// import "./loginStyle.less";
import service from "../service";

class Reg extends Component {
  state = {
    us: "",
    ps: "",
  };
  onReg = async () => {
    // console.log(111);
    const { err} = await service.Reg(this.state.us, this.state.ps);
    if (err === 0) {
      console.log("注册成功");
      alert("恭喜您，注册成功！");
      alert("去登录");
      // this.$router.replace("/login")
    } 
    return
  };
  render() {
    return (
      <div className="Login">
        <form className="form">
          <div className="formItem">
            <label htmlFor="username">用户名：</label>
            <input
              type="text"
              id="username"
              value={this.state.us}
              onChange={(e) => {
                this.setState({ us: e.target.value });
              }}
            />
          </div>
          <div className="formItem">
            <label htmlFor="password">密码：</label>
            <input
              type="password"
              id="password"
              value={this.state.ps}
              onChange={(e) => {
                this.setState({ ps: e.target.value });
              }}
            />
          </div>
          <div className="loginBtn">
            <button className="logindl" onClick={this.onReg}>
              注册
            </button>
          </div>
        </form>
      </div>
    );
  }
}

export default Reg;
